Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: extract out allocate_stack_0 to work around a "Local Exec" TLS model issue and prevent segfaulting #458

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

kkysen
Copy link
Contributor

@kkysen kkysen commented Oct 28, 2024

allocate_stack_0 writes the allocated stack to ia2_stackptr_0. Previously, this was done inline in init_stacks_and_setup_tls, which is defined in the main compartment with INIT_RUNTIME, and thus may sometimes use the "Local Exec" TLS model and thus use a different thread-local address. Moving this to allocate_stack_0 in libia2 forces it to use the correct GOT thread local.

This is a workaround to #457, but doesn't actually fix the root issue, so I'm not sure if we should merge it instead of fixing #457 properly. But it does successfully prevent compartmentalized dav1d from segfaulting, and thus is included in #454.

… TLS model issue and prevent segfaulting

`allocate_stack_0` writes the allocated stack to `ia2_stackptr_0`.
Previously, this was done inline in `init_stacks_and_setup_tls`,
which is defined in the main compartment with `INIT_RUNTIME`,
and thus may sometimes use the "Local Exec" TLS model and thus use a different thread-local address.
Moving this to `allocate_stack_0` in `libia2` forces it to use the correct GOT thread local.

This is a workaround to #457, but doesn't actually fix the root issue.
It does successfully prevent compartmentalized `dav1d` from segfaulting, though.
@ayrtonm ayrtonm merged commit d819ae5 into main Nov 18, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants